import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";

const routes: RouteRecordRaw[] = [
  {
    path: "/",
    component: () => import("@/views/layout/Layout.vue"),
    children: [
      {
        path: "",
        name: "Home",
        component: () => import("@/views/home/Home.vue"),
      },
      {
        path: "api-manage",
        name: "ApiManage",
        component: () => import("@/views/api-manage/ApiManage.vue"),
      },
      {
        path: "data-source",
        name: "DataSource",
        component: () => import("@/views/data-source/DataSource.vue"),
      },
      {
        path: "permission",
        name: "Permission",
        component: () => import("@/views/permission/Permission.vue"),
      },
    ],
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

router.beforeEach((to, from, next) => {
  console.log("路由变化:", { to, from });
  next();
});

export default router;
